from time import sleep
import uiautomation
import pyautogui

class chuyuan():
        his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
        his.SetFocus()
        chuyuanchuangkou = his.WindowControl(ClassName='Window',Name='出 院')
        chuyuanzhuangtai = chuyuanchuangkou.ComboBoxControl(AutomationId='cb_cyzt',foundIndex=1)

        #选择出院状态
        def choose_cyzt(self,name):
                self.chuyuanzhuangtai.Click()
                all_shuju = self.chuyuanzhuangtai.GetChildren()
                for i in all_shuju:
                        if i.GetFirstChildControl().Name == name:
                                i.Click()

        liyuanfangshi = chuyuanchuangkou.ComboBoxControl(ClassName='ComboBox',foundIndex=2)
        #选择离院方式
        def choose_lyfs(self,name):
                self.liyuanfangshi.Click()
                all_shuju = self.liyuanfangshi.GetChildren()
                for i in all_shuju:
                        if i.GetFirstChildControl().Name == name:
                                i.Click()

        #是否有31天内再住院计划
        zaizhuyuanjihua = chuyuanchuangkou.ComboBoxControl(ClassName='ComboBox',foundIndex=3)
        #选择是否有31天内再住院计划
        def choose_zzyjh(self,name):
                self.zaizhuyuanjihua.Click()
                all_shuju = self.zaizhuyuanjihua.GetChildren()
                for i in all_shuju:
                        if i.GetFirstChildControl().Name == name:
                                i.Click()

        #选项卡
        #长期医嘱
        changqiyizhu = chuyuanchuangkou.TabControl(ClassName='TabControl').TabItemControl(ClassName='TabItem',Name='长期医嘱')
        linshiyizhu =chuyuanchuangkou.TabControl(ClassName='TabControl').TabItemControl(ClassName='TabItem',Name='临时医嘱')
        fayaoqqinglindan =chuyuanchuangkou.TabControl(ClassName='TabControl').TabItemControl(ClassName='TabItem',Name='发药请领单')
        daichulidefeiyong =chuyuanchuangkou.TabControl(ClassName='TabControl').TabItemControl(ClassName='TabItem',Name='待处理的费用')
        shenhezhuyuanfeiyong = chuyuanchuangkou.TabControl(ClassName='TabControl').TabItemControl(ClassName='TabItem',Name='审核住院费用')
        def click_cqyz(self):
                self.changqiyizhu.Click()
        def click_lsyz(self):
                self.linshiyizhu.Click()
        def click_fyqld(self):
                self.fayaoqqinglindan.Click()
        def click_dclfy(self):
                self.daichulidefeiyong.Click()
        def click_shzyfy(self):
                self.shenhezhuyuanfeiyong.Click()
        def all_click(self):
                self.click_cqyz()
                self.click_lsyz()
                self.click_fyqld()
                self.click_dclfy()
                self.click_shzyfy()

        chuyuananniu = chuyuanchuangkou.ButtonControl(AutomationId='cysave_btn',ClassName='Button',Name='出院')
        #点击出院
        def click_cy(self):
                self.chuyuananniu.Click()